const { Article } = require('../../model/article');
const { Category } = require('../../model/Category');
const pagination = require('mongoose-sex-page');
module.exports = async (req,res)=>{
  let page = req.query.page;
  //文章分类
  let category = await Category.find();
  let articles = await pagination(Article).find({state: 1,classify: req.query.id}).page(page).size(6).display(5).populate('author').exec();
  articles = JSON.stringify(articles);
  articles = JSON.parse(articles);
  res.render('index',{
    articles,
    category
  });
}